//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package sto.android.app;

import android.content.Context;
import android.content.Intent;
import java.io.UnsupportedEncodingException;
import java.util.Calendar;
import java.util.Date;
import sto.android.app.StoJNI.ScanCallBack;

public class RX70Scanner {
    public static RX70Scanner instance = null;
    public ScanCallBack scanCallBack;
    private static boolean bScanning = false;
    boolean m_soft = false;
    Context m_contextContext = null;

    static {
        System.loadLibrary("RX70Dev");
    }

    public RX70Scanner() {
    }

    public static synchronized RX70Scanner getInstance() {
        if(instance == null) {
            instance = new RX70Scanner();
        }

        return instance;
    }

    public void Barcode_open() {
        this.close();
        this.close();
        this.open();
    }

    public void Barcode_Close() {
        this.close();
    }

    public void Barcode_StartScan() {
        this.SetScannerStop();

        try {
            Thread.sleep(10L);
        } catch (InterruptedException var2) {
            var2.printStackTrace();
        }

        this.SetScannerStart();
    }

    public void Barcode_StopScan() {
        this.SetScannerStop();
    }

    public void ScanResults(byte[] str) {
        if(this.scanCallBack != null) {
            String info = "";

            try {
                info = new String(str, "UTF-8");
                if(info != null && info.length() > 0) {
                    this.scanCallBack.onScanResults(info);
                }
            } catch (UnsupportedEncodingException var4) {
                var4.printStackTrace();
            }

        }
    }

    public int Barcode_Write(byte[] data) {
        return this.write(data);
    }

    private native void open();

    private native void close();

    private native void SetScannerStart();

    private native void SetScannerStop();

    public native void setpowerstate(int var1);

    public native int write(byte[] var1);

    public native int GetPlatform();

    public native String GetMachineCode(Context var1);

    public void SetSystemTime(Context context, String mm) {
        long lDate = Long.valueOf(mm).longValue();
        Date nowTime = new Date(lDate);
        Calendar cal = Calendar.getInstance();
        cal.setTime(nowTime);
        int year = cal.get(1);
        int month = cal.get(2) + 1;
        int day = cal.get(5);
        int hour = cal.get(11);
        int minute = cal.get(12);
        int second = cal.get(13);
        Intent intent = new Intent("com.System.TimeSetting");
        intent.putExtra("year", year);
        intent.putExtra("month", month);
        intent.putExtra("day", day);
        intent.putExtra("hour", hour);
        intent.putExtra("minute", minute);
        intent.putExtra("second", second);
        context.sendBroadcast(intent);
    }
}
